package wnhz.com.business.shareshop.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import wnhz.com.business.R;
import wnhz.com.business.base.BaseActivity;
import wnhz.com.business.groupshop.ui.YanZhengCardActivity;
import wnhz.com.business.impl.ActionBarClickListener;
import wnhz.com.business.uitls.CustomerKeyboard;
import wnhz.com.business.uitls.PasswordEditText;
import wnhz.com.business.uitls.dialog.CommonDialog;
import wnhz.com.business.view.TranslucentActionBar;

import static android.R.attr.editable;

//共享商城添加银行卡
public class AddBankCardActivityS extends BaseActivity implements ActionBarClickListener {

    @BindView(R.id.actionbar)
    TranslucentActionBar actionbar;
    @BindView(R.id.et_name)
    EditText etName;
    @BindView(R.id.et_cardnumber)
    EditText etCardnumber;
    @BindView(R.id.et_cardname)
    EditText et_cardname;
    @BindView(R.id.tv_next)
    TextView tvNext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_bank_cards);
        ButterKnife.bind(this);
        actionbar.setData("添加银行卡", R.drawable.ic_lefft_white, null, 0, null, 0, this);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            actionbar.setStatusBarHeight(getStatusBarHeight());
        }
        et_cardname.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (et_cardname.getText().toString().equals("")||et_cardname.getText().toString()==null){
                    tvNext.setTextColor(getResources().getColor(R.color.text51));
                    tvNext.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_circle_grayd));
                    tvNext.setOnClickListener(null);
                }else
                {
                    tvNext.setTextColor(getResources().getColor(R.color.white));
                    tvNext.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_circle_reds));
                    tvNext.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            if (TextUtils.isEmpty(et_cardname.getText().toString())||etName.getText().toString().equals("")||etName.getText().toString()==null&&
                                    etCardnumber.getText().toString().equals("")||etCardnumber.getText().toString()==null)
                            {
                                MyToast("请完善信息");
                            }else
                            {
                                Intent intent = new Intent(AddBankCardActivityS.this,YanZhengCardActivityS.class);
                                intent.putExtra("name", etName.getText().toString());
                                intent.putExtra("bank_num", etCardnumber.getText().toString());
                                intent.putExtra("bank_name", et_cardname.getText().toString());
                                startActivity(intent);
                                finish();
                            }
//                                    }
                        }
                    });
                }
            }
        });
    }


    public static Intent createIntent(Context context) {
        Intent intent = new Intent(context, AddBankCardActivityS.class);
        return intent;
    }


    @Override
    public void onLeftClick() {
        finish();

    }

    @Override
    public void onRightClick() {


    }

    @Override
    public void onEditTextClick() {

    }

    @OnClick(R.id.tv_next)
    public void onViewClicked() {

    }
       
}
